﻿using Envision4IT.Adapters.Interfaces;
using Envision4IT.data;
using Envision4IT.Models;
using System.Collections.Generic;
using System.Linq;

namespace Envision4IT.Adapters.Adapters
{
    public class AdminAdapter : IAdminAdapter
    {
        public List<AdminVM> GetAdminControl()
        {
            List<AdminVM> model;
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                model = db.Projects.Where(x => x.DateDeleted == null && x.CompletionDate == null).OrderByDescending(x => x.StartDate).Take(10).Select(x => new AdminVM()
                    {
                        ProjectName = x.ProjectName,
                        StartDate = x.StartDate,
                        UserID = x.UserID
                    }).ToList();
            }
            return model;
        }
    }
}